<%@ page import="com.itheima.domain.User" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.HashMap" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/7/6
  Time: 20:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>使用EL取出不同类似的数据值</title>
</head>
<body>
<h2>得到实体类的值</h2>
<%
    //创建一个User对象
    User user = new User(18, "张三", false, 114);
    //将user添加到页面域中
    pageContext.setAttribute("uu",user);
%>
<%--通过键去取值，本质上是调用了User中的get方法--%>
年龄：${uu.age} 姓名：${uu.name}
<hr/>
<h2>得到List集合的值</h2>
<%
    ArrayList<String> users = new ArrayList<>();
    users.add("张三");
    users.add("李四");
    request.setAttribute("user",users);
%>
${user[0]} ，${user[1]}

<hr/>
<h2>得到Map集合的值</h2>
<%
    HashMap<String,String> map=new HashMap<>();
    map.put("t001","张无忌");
    map.put("t002","张三丰");
    map.put("t001-t004","周芷若");
    pageContext.setAttribute("person",map);
%>
<%--语法：${map对象.键}或${map对象["键"]}--%>
${person.t001} ,${person.t002},${person["t001-t004"]}



</body>
</html>
